from functools import wraps

# 使用包裹函数，用于指定输出的日志文件
def logit(logfile ='out.log'):
	def logging_decorator(func):
		@wraps(func)
		def wrapped_function(*agrs,**kwargs):
			log_string = func.__name__ + " was called"
			print(log_string)
			# 打开logfile，写入内容
			with open(logfile,'w') as opened_file:
				opened_file.write(log_string)
			return func(*agrs,**kwargs)
		print("wrapped_function")
		return wrapped_function
	print("return logging_decorator")
	return logging_decorator

@logit()
def myfunc1():
	pass

myfunc1()

print("------func2-----")
@logit(logfile = 'func2.log')
def myfunc2():
	pass

myfunc2()